test.beforeEach(async ({ loginWithValidCredentials, addProductToCart, proceedToCheckout, proceedToPayment }, testInfo) => {
const account = accounts[testInfo.workerIndex % accounts.length]; // Assign account based on worker index
const test = base.extend({
homepage: async ({ page }, use) => {
const test = base.extend({
homepage: async ({ page }, use) => {
testInfo.account = account; // Store the account information in testInfo
await page.goto(account.baseUrl);
await homepage.navigateToPage('login');
case 'login':
await this.login.click();
break;
async loginExistingUser(username, password) {
await this.loginUsername.fill(username);
await this.loginPassword.fill(password);
await this.loginUsername.fill(username);
await this.loginPassword.fill(password);
await this.loginButton.click();
await this.loginPassword.fill(password);
await this.loginButton.click();
}
const test = base.extend({
homepage: async ({ page }, use) => {
const test = base.extend({
homepage: async ({ page }, use) => {
const productCard = await this.productCards;
const allProductsCounts = await productCard.count();
for (let i = 0; i < allProductsCounts; i++) {
const singleProduct = await productCard.nth(i).locator('div p').nth(0).textContent();
for (const product of randomProductData) {
for (let i = 0; i < allProductsCounts; i++) {
const singleProduct = await productCard.nth(i).locator('div p').nth(0).textContent();
for (const product of randomProductData) {
for (let i = 0; i < allProductsCounts; i++) {
const singleProduct = await productCard.nth(i).locator('div p').nth(0).textContent();
for (const product of randomProductData) {
for (let i = 0; i < allProductsCounts; i++) {
const singleProduct = await productCard.nth(i).locator('div p').nth(0).textContent();
for (const product of randomProductData) {
for (let i = 0; i < allProductsCounts; i++) {
const singleProduct = await productCard.nth(i).locator('div p').nth(0).textContent();
for (const product of randomProductData) {
const homeProductName = singleProduct;
const homeProductThumbnail = await productCard.nth(i).locator('div img').getAttribute('src');
const homeProductPrice = (await productCard.nth(i).locator('div h2').first().textContent()).replace('Rs. ', '');
const homeProductThumbnail = await productCard.nth(i).locator('div img').getAttribute('src');
const homeProductPrice = (await productCard.nth(i).locator('div h2').first().textContent()).replace('Rs. ', '');
// Click the product to view product detail page
await productCard.nth(i).locator('div a').nth(0).click();
if (productAddedtoCart.length < randomProductData.length) {
const modal = this.continueModal;
await modal.waitFor({ state: 'visible' });
await modal.click();
await modal.waitFor({ state: 'visible' });
await modal.click();
} else {
for (let i = 0; i < allProductsCounts; i++) {
const singleProduct = await productCard.nth(i).locator('div p').nth(0).textContent();
for (const product of randomProductData) {
for (let i = 0; i < allProductsCounts; i++) {
const singleProduct = await productCard.nth(i).locator('div p').nth(0).textContent();
for (const product of randomProductData) {
for (let i = 0; i < allProductsCounts; i++) {
const singleProduct = await productCard.nth(i).locator('div p').nth(0).textContent();
for (const product of randomProductData) {
const homeProductName = singleProduct;
const homeProductThumbnail = await productCard.nth(i).locator('div img').getAttribute('src');
const homeProductPrice = (await productCard.nth(i).locator('div h2').first().textContent()).replace('Rs. ', '');
const homeProductThumbnail = await productCard.nth(i).locator('div img').getAttribute('src');
const homeProductPrice = (await productCard.nth(i).locator('div h2').first().textContent()).replace('Rs. ', '');
// Click the product to view product detail page
await productCard.nth(i).locator('div a').nth(0).click();
if (productAddedtoCart.length < randomProductData.length) {
const modal = this.viewCartModal;
await modal.waitFor({ state: 'visible' });
await modal.click();
await modal.waitFor({ state: 'visible' });
await modal.click();
}
const cartRows = await this.cartRowsLocator;
const cartRowsCount = await cartRows.count();
let cartDetails = [];
let cartDetails = [];
const cartPageName = await this.pageName.textContent();
// Extract details for each product in the cart
const cartProductThumbnail = await row.locator('td a img').getAttribute('src');
const cartProductName = await row.locator('td h4 a').textContent();
const cartProductThumbnail = await row.locator('td a img').getAttribute('src');
const cartProductName = await row.locator('td h4 a').textContent();
const cartProductCategory = await row.locator('td p').nth(0).textContent();
const cartProductName = await row.locator('td h4 a').textContent();
const cartProductCategory = await row.locator('td p').nth(0).textContent();
const cartProductPrice = (await row.locator('td p').nth(1).textContent()).replace('Rs. ', '');
const cartProductCategory = await row.locator('td p').nth(0).textContent();
const cartProductPrice = (await row.locator('td p').nth(1).textContent()).replace('Rs. ', '');
const cartProductQuantity = await row.locator('td button').textContent();
const cartProductPrice = (await row.locator('td p').nth(1).textContent()).replace('Rs. ', '');
const cartProductQuantity = await row.locator('td button').textContent();
const cartProductTotal = (await row.locator('td p').nth(2).textContent()).replace('Rs. ', '');
const cartProductQuantity = await row.locator('td button').textContent();
const cartProductTotal = (await row.locator('td p').nth(2).textContent()).replace('Rs. ', '');
const cartProductManualTotal = String(cartProductPrice * cartProductQuantity); // Price * Quantity
// Extract details for each product in the cart
const cartProductThumbnail = await row.locator('td a img').getAttribute('src');
const cartProductName = await row.locator('td h4 a').textContent();
const cartProductThumbnail = await row.locator('td a img').getAttribute('src');
const cartProductName = await row.locator('td h4 a').textContent();
const cartProductCategory = await row.locator('td p').nth(0).textContent();
const cartProductName = await row.locator('td h4 a').textContent();
const cartProductCategory = await row.locator('td p').nth(0).textContent();
const cartProductPrice = (await row.locator('td p').nth(1).textContent()).replace('Rs. ', '');
const cartProductCategory = await row.locator('td p').nth(0).textContent();
const cartProductPrice = (await row.locator('td p').nth(1).textContent()).replace('Rs. ', '');
const cartProductQuantity = await row.locator('td button').textContent();
const cartProductPrice = (await row.locator('td p').nth(1).textContent()).replace('Rs. ', '');
const cartProductQuantity = await row.locator('td button').textContent();
const cartProductTotal = (await row.locator('td p').nth(2).textContent()).replace('Rs. ', '');
const cartProductQuantity = await row.locator('td button').textContent();
const cartProductTotal = (await row.locator('td p').nth(2).textContent()).replace('Rs. ', '');
const cartProductManualTotal = String(cartProductPrice * cartProductQuantity); // Price * Quantity
const test = base.extend({
homepage: async ({ page }, use) => {
const test = base.extend({
homepage: async ({ page }, use) => {
const cartVisible = await this.pageName;
await cartVisible.waitFor({ state: 'visible' });
await this.proceedtoCheckoutpage.click();
await cartVisible.waitFor({ state: 'visible' });
await this.proceedtoCheckoutpage.click();
}
const checkoutRows = await this.checkoutRowsLocator;
const checkoutRowsCount = await checkoutRows.count();
const checkoutPageName = await this.pageName.textContent();
const checkoutRowsCount = await checkoutRows.count();
const checkoutPageName = await this.pageName.textContent();
let checkoutDetails = [];
// Extract details for each product in the cart
let checkoutProductThumbnail = await row.locator('td a img').getAttribute('src');
let checkoutProductName = await row.locator('td h4 a').textContent();
let checkoutProductThumbnail = await row.locator('td a img').getAttribute('src');
let checkoutProductName = await row.locator('td h4 a').textContent();
let checkoutProductCategory = await row.locator('td p').nth(0).textContent();
let checkoutProductName = await row.locator('td h4 a').textContent();
let checkoutProductCategory = await row.locator('td p').nth(0).textContent();
let checkoutProductPrice = (await row.locator('td p').nth(1).textContent()).replace('Rs. ', '');
let checkoutProductCategory = await row.locator('td p').nth(0).textContent();
let checkoutProductPrice = (await row.locator('td p').nth(1).textContent()).replace('Rs. ', '');
let checkoutProductQuantity = await row.locator('td button').textContent();
let checkoutProductPrice = (await row.locator('td p').nth(1).textContent()).replace('Rs. ', '');
let checkoutProductQuantity = await row.locator('td button').textContent();
let checkoutProductTotal = (await row.locator('td p').nth(2).textContent()).replace('Rs. ', '');
let checkoutProductQuantity = await row.locator('td button').textContent();
let checkoutProductTotal = (await row.locator('td p').nth(2).textContent()).replace('Rs. ', '');
let checkoutProductManualTotal = String(checkoutProductPrice * checkoutProductQuantity);
// Extract details for each product in the cart
let checkoutProductThumbnail = await row.locator('td a img').getAttribute('src');
let checkoutProductName = await row.locator('td h4 a').textContent();
let checkoutProductThumbnail = await row.locator('td a img').getAttribute('src');
let checkoutProductName = await row.locator('td h4 a').textContent();
let checkoutProductCategory = await row.locator('td p').nth(0).textContent();
let checkoutProductName = await row.locator('td h4 a').textContent();
let checkoutProductCategory = await row.locator('td p').nth(0).textContent();
let checkoutProductPrice = (await row.locator('td p').nth(1).textContent()).replace('Rs. ', '');
let checkoutProductCategory = await row.locator('td p').nth(0).textContent();
let checkoutProductPrice = (await row.locator('td p').nth(1).textContent()).replace('Rs. ', '');
let checkoutProductQuantity = await row.locator('td button').textContent();
let checkoutProductPrice = (await row.locator('td p').nth(1).textContent()).replace('Rs. ', '');
let checkoutProductQuantity = await row.locator('td button').textContent();
let checkoutProductTotal = (await row.locator('td p').nth(2).textContent()).replace('Rs. ', '');
let checkoutProductQuantity = await row.locator('td button').textContent();
let checkoutProductTotal = (await row.locator('td p').nth(2).textContent()).replace('Rs. ', '');
let checkoutProductManualTotal = String(checkoutProductPrice * checkoutProductQuantity);
for (let i = 0; i < count; i++) {
const addressDetail = await addressElements.nth(i).textContent();
retrievedAddress.push(addressDetail.trim());
for (let i = 0; i < count; i++) {
const addressDetail = await addressElements.nth(i).textContent();
retrievedAddress.push(addressDetail.trim());
for (let i = 0; i < count; i++) {
const addressDetail = await addressElements.nth(i).textContent();
retrievedAddress.push(addressDetail.trim());
for (let i = 0; i < count; i++) {
const addressDetail = await addressElements.nth(i).textContent();
retrievedAddress.push(addressDetail.trim());
for (let i = 0; i < count; i++) {
const addressDetail = await addressElements.nth(i).textContent();
retrievedAddress.push(addressDetail.trim());
for (let i = 0; i < count; i++) {
const addressDetail = await addressElements.nth(i).textContent();
retrievedAddress.push(addressDetail.trim());
for (let i = 0; i < count; i++) {
const addressDetail = await addressElements.nth(i).textContent();
retrievedAddress.push(addressDetail.trim());
for (let i = 0; i < count; i++) {
const addressDetail = await addressElements.nth(i).textContent();
retrievedAddress.push(addressDetail.trim());
for (let i = 0; i < count; i++) {
const addressDetail = await addressElements.nth(i).textContent();
retrievedAddress.push(addressDetail.trim());
for (let i = 0; i < count; i++) {
const addressDetail = await addressElements.nth(i).textContent();
retrievedAddress.push(addressDetail.trim());
for (let i = 0; i < count; i++) {
const addressDetail = await addressElements.nth(i).textContent();
retrievedAddress.push(addressDetail.trim());
for (let i = 0; i < count; i++) {
const addressDetail = await addressElements.nth(i).textContent();
retrievedAddress.push(addressDetail.trim());
for (let i = 0; i < count; i++) {
const addressDetail = await addressElements.nth(i).textContent();
retrievedAddress.push(addressDetail.trim());
for (let i = 0; i < count; i++) {
const addressDetail = await addressElements.nth(i).textContent();
retrievedAddress.push(addressDetail.trim());
for (let i = 0; i < count; i++) {
const addressDetail = await addressElements.nth(i).textContent();
retrievedAddress.push(addressDetail.trim());
for (let i = 0; i < count; i++) {
const addressDetail = await addressElements.nth(i).textContent();
retrievedAddress.push(addressDetail.trim());
const test = base.extend({
homepage: async ({ page }, use) => {
const test = base.extend({
homepage: async ({ page }, use) => {
async proceedtoPayment(){
await this.proceedtoPaymentPage.click();
}
async enterPaymentDetails(name, number, cvs, monthexp, yearexp) {
await this.nameOnCard.pressSequentially(name);
await this.cardNumber.pressSequentially(String(number));
await this.nameOnCard.pressSequentially(name);
await this.cardNumber.pressSequentially(String(number));
await this.cvs.pressSequentially(String(cvs));
await this.cardNumber.pressSequentially(String(number));
await this.cvs.pressSequentially(String(cvs));
await this.expirationMM.pressSequentially(String(monthexp));
await this.cvs.pressSequentially(String(cvs));
await this.expirationMM.pressSequentially(String(monthexp));
await this.expirationYYYY.pressSequentially(String(yearexp));
await this.expirationMM.pressSequentially(String(monthexp));
await this.expirationYYYY.pressSequentially(String(yearexp));